package com.eheart.demo_jdk21.effective;

/**
 * @Classname
 * @Date 2024/5/30 10:06
 * @CreateBy pan jin
 * Description demo_jdk21
 */
public class ColorPoint extends Point{
    private int color;

    public ColorPoint(int x, int y, int color) {
        super(x, y);
        this.color = color;
    }

    @Override
    public boolean equals(Object obj) {

        if (!(obj instanceof ColorPoint)) {
            return false;
        }
        return super.equals(obj) && ((ColorPoint) obj).color == color;
    }

    public static void main(String[] args) {
        Point p = new ColorPoint(1, 2, 3);
        Point q = new Point(1, 2);
        System.out.println(p.equals(q));
        System.out.println(q.equals(p));
    }
}
